package 设计模式.结构型.代理模式;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import 设计模式.结构型.代理模式.anno.ExceptionHandleAnno;
import 设计模式.结构型.代理模式.anno.InvokeRecordAnno;

import java.util.HashMap;
import java.util.Map;

/**
 * @author lchenglong
 * @date 2024/1/25
 */
@RestController
@RequestMapping("proxy")
public class ProxyTestController {

    @GetMapping("test")
    @ExceptionHandleAnno
    @InvokeRecordAnno("测试代理模式")
    public Map<String, Object> testProxy(@RequestParam String biz,
                                         @RequestParam String param) {
        if (biz.equals("abc")) {
            throw new IllegalArgumentException("非法的 biz=" + biz);
        }
        Map<String, Object> result = new HashMap<>(4);
        result.put("id", 123);
        result.put("nick", "chengLong");
        return result;
    }
}
